<?php echo $this->render('layouts/__header.phtml'); ?>
<?php echo $this->render('layouts/__nav.phtml'); ?>

<link rel="stylesheet" type="text/css" href="/css/ticket.css" />

		<form id="ticket_edit_form" action="<?php echo $this->this_url; ?>" method="post" enctype="multipart/form-data">
		<input type="hidden" id="has_attachment" name="has_attachment" />
		
			<h2>Edit Ticket <?php echo $this->ticket['id']; ?></h2>
			<table class="table550">
				<tr><td>&nbsp;</td></tr>
				<tr>
					<td>
						<span class="left">Requester</span>
						<?php echo $this->formSelect('requester_id', $this->ticket['requester_id'], null, $this->entites['requester']) ?>
					</td>
				    <td>
						<span>Replier</span>
						<?php echo $this->formSelect('replier_id', $this->ticket['replier_id'], null, $this->entites['manager']) ?>
					</td>
				</tr>
				<tr>
				    <td>
						<span class="left">Property</span>
						<?php echo $this->formSelect('property_id', $this->ticket['property_id'], null, $this->entites['property']) ?>
					</td>
				    <td>
						<span>Status</span>
						<?php echo $this->formSelect('status', $this->ticket['status'], null, $this->entites['status']) ?>
					</td>
				</tr>
				<tr>
					<td colspan="2" style="color:#000;font-weight:bold">Ticket Type</td>
				</tr>
				<tr>
					<td colspan="2"><?php echo $this->formRadio('ticket_type', $this->ticket['ticket_type'], array('style' => 'width:68px'), $this->entites['ticket_type']) ?></td>
				</tr>
				<tr>
					<td colspan="2"><span class="left">Title</span></td>
				</tr>
				<tr>
					<td colspan="2"><input id="title" name="title" type="text" class="ticket_title" value="<?php echo $this->ticket['title'];?>" /></td>
				</tr>
				<tr>
					<td colspan="2"><span class="left">Content</span></td>
				</tr>
				<tr>
					<td colspan="2"><textarea name="content"><?php echo $this->ticket['content']; ?></textarea></td>
			    </tr>
				<tr>
					<td colspan="2"><span class="common left">Background</span></td>
				</tr>
				<tr>
					<td colspan="2"><textarea name="background"><?php echo $this->ticket['background']; ?></textarea></td>
			    </tr>
				<tr>
					<td colspan="2"><span class="common left">Attachment</span></td>
				</tr>
				<tr>
					<td colspan="2"><input id="attachment_file" name="attachment_file" type="file" /></td>
				</tr>
				<tr>
					<td colspan="2"><div id="attachment_box"><iframe id="upload_frame" name="upload_frame" src="<?php echo $this->upload_url; ?>" frameborder="0"></iframe></div></td>
				</tr>
				<tr><td colspan="2" class="spacing"></td></tr>
				<tr>
					<td colspan="2"><input type="submit" name="save" value="Save" class="but" /><input id="cancelbtn" type="button" value="Cancel" class="but" /></td>
				</tr>
			</table>

		</form>

		<div id="uploadingbox" style="display:none;padding:2px 0px 0px 8px;width:125px;height:20px;text-align:center;position:absolute;top:0px;right:0px;background:#CC0000;color:#fff;z-index:10000;"><b>Uploading ...</b></div>

<script type="text/javascript" src="/js/mootools.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
<script type="text/javascript">
window.addEvent('domready', function(){
	$('cancelbtn').addEvent('click', function(e){	
		e = new Event(e);
		redirect('<?php echo $this->page_url;?>');
		e.stop();
	});
	$('attachment_file').addEvent('change', function(e){
		e = new Event(e);
		$('has_attachment').value = 'yes';
		var old_action = $('ticket_edit_form').action;
		// submit to iframe once
		$('ticket_edit_form').action = '<?php echo $this->upload_url; ?>';
		$('ticket_edit_form').target = 'upload_frame';
		$('ticket_edit_form').submit();
		// return to normal form
		$('ticket_edit_form').action = old_action;
		$('ticket_edit_form').target = '';
		e.stop();
	});
});
</script>

<?php echo $this->render('layouts/__footer.phtml'); ?>